﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace BDSim
{
    //接收机对单颗卫星的观测数据
    public struct ReceiverSingleSatObs
    {
        public int SatID;					//可见卫星编号
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
        public double[] Code_Pseudo;	        //6个频点观测伪距
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
        public double[] Carrier_Phase;		//6个频点载波相位测量值
    };

    //单颗卫星导航电文参数
    public struct NavMessage
    {
        //卫星编号
        public int SatID;
        //钟差参数
        public ClkErrFitMsg ClkErrMsg;

        //星历16参数
        public Ephemeris_16 EphemerisSixteen;

        //电离层8参数
        public IonoSphere_8 IonEightParam;
    };

    //接收机收到的单颗可见星的信息，包括观测数据、可见星的电文
    public struct SatInfo
    {
        public int SatID;					//可见卫星编号
        public ReceiverSingleSatObs SatObs;
        public NavMessage SingleSatNavMsg;
    };

    [StructLayout(LayoutKind.Sequential)]
    public struct PPositionning_Input
    {
        public UTCTime CurTime;               //观测时刻
        public int ReceiverID;                 //本地接收机编号
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public double[] ReceiverPos;                //估值向量概略坐标

        public int ObsTotalSatnum;     //可见卫星总数
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
        public SatInfo[] ObsSatInfo;     //接收机收到的单颗可见星的信息，包括观测数据、可见星的电文

        //观测精度
        public double Sigma0;

        public EConstellationType SysType; //系统类型

    };

    [StructLayout(LayoutKind.Sequential)]
    public struct PPositionning_Param
    {
        public int m_nMode;             //  处理模式:
        //      1=已知导航电文星历、钟差、8参数电离层
        //      2=已知导航电文星历、钟差，电离层延迟采用双频改正


        public int Iion;				//	电离层一级开关，
        public int Itro;				//	对流层一级开关，
        public int Irel;				//	相对论效应一级开关，
        public int Iclo;               //卫星钟差开关

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public double[] Freq;				//  频率

    };

    public struct PPositionning_Output
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public double[] X;              //估计值
        public DopDLL.DopOutput DOP;  //update by lijing 2016.07.26 21:47
    };

    /// <summary>
    /// 导航服务性能计算输出结构体
    /// </summary>
    public struct Dop_Output
    {
        /// <summary>
        /// 几何精度因子
        /// </summary>
        public double GDOP;

        /// <summary>
        /// 位置精度因子
        /// </summary>
        public double PDOP;

        /// <summary>
        /// 水平精度因子
        /// </summary>
        public double HDOP;

        /// <summary>
        /// 垂直精度因子
        /// </summary>
        public double VDOP;

        /// <summary>
        /// 时间精度因子
        /// </summary>
        public double TDOP;

        /// <summary>
        /// 可见星数目
        /// </summary>
        public int AccessNum;

        public double HNSP;
        public double VNSP;
        public double PNSP;
        public double TNSP;
    }

    /// <summary>
    /// 接收机定位、测速、授时输出结果（含DOP值）
    /// </summary>
    public struct PVTOutputData
    {
        /// <summary>
        /// 定位结果，CGCS2000直角坐标系中位置
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public double[] Pos;

        /// <summary>
        /// 测速结果，CGCS2000直角坐标系中速度
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public double[] Vel;

        /// <summary>
        /// 授时结果
        /// </summary>
        public double DeltT;

        /// <summary>
        /// 定位精度因子
        /// </summary>
        public Dop_Output DopOutputData;
    }

}
